package com.servlet;

import com.pojo.Response;
import com.util.CookieUtil;
import com.util.JsonUtil;
import com.util.TokenUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(value = "/jwtServlet")
public class JwtServlet extends BaseServlet{
    protected void jwt_versify(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Cookie cookie= CookieUtil.findCookie("Token",req.getCookies());
        if(TokenUtil.verify(cookie.getValue())){
            resp.getWriter().write(JsonUtil.toJson(new Response(107,"jwt验证成功",null)));
        }else{
            resp.getWriter().write(JsonUtil.toJson(new Response(108,"jwt验证失败",null)));
        }
    }
}
